package cn.bdqn.controller.sys;

import cn.bdqn.entity.Entry;
import cn.bdqn.service.sys.SysEntryService;
import cn.bdqn.utils.MyLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @ProjectName: ycbdqn
 * @Package: cn.bdqn.controller.sys
 * @Author: huat
 * @Date: 2020/3/12 20:03
 * @Version: 1.0
 */
@RequestMapping("/sys/entry")
@Controller
public class SysEntryController {
    @Autowired
    SysEntryService sysEntryService;
    /**
     * 进入就业学员页面
     * @return
     */
    @RequestMapping("intoEntry")
    public String intoEntry(){
        return "entry/entry";
    }

    /**
     * 获取就业学生信息
     * @param page 起始页
     * @param limit 页面大小
     * @param studentName   就业学生姓名
     * @return
     */
    @RequestMapping("getEntry")
    @ResponseBody
    @MyLog("获取毕业学员信息")
    public Map<String,Object> getEntry(int page,int limit,String studentName){
        return sysEntryService.getEntry(page, limit, studentName);
    }

    /**
     * 根据id删除就业学员
     * @param id 就业学生id
     * @return
     */
    @RequestMapping("deleteEntryById")
    @ResponseBody
    @MyLog("删除就业学员")
    public boolean deleteEntryById(int id){

        return sysEntryService.deleteEntryById(id);
    }

    /**
     * 进入修改页面
     * @param id
     * @param model
     * @return
     */
    @RequestMapping("intoUpdateEntry")
    public String intoUpdateEntry(int id, Model model){
        model.addAttribute("entry",sysEntryService.getEntryById(id));
        return "entry/updateEntry";
    }

    /**
     * 修改就业学员
     * @param request
     * @param entry
     * @return
     */
    @RequestMapping("updateEntry")
    @ResponseBody
    @MyLog("修改就业学员")
    public String updateEntry(HttpServletRequest request, Entry entry){
        return sysEntryService.updateEntry(request,entry);
    }

    /**
     * 进入增加学员页面
     * @return
     */
    @RequestMapping("intoAddEntry")
    public String intoAddEntry(){
        return "entry/addEntry";
    }
    /**
     * 新增就业学员
     * @param request
     * @param entry
     * @return
     */
    @RequestMapping("addEntry")
    @ResponseBody
    @MyLog("新增就业学员")
    public String addEntry(HttpServletRequest request, Entry entry){
        return sysEntryService.addEntry(request,entry);
    }
}
